package com.zlq.cn.controller.sign.juhe;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zlq.cn.api.SignApiResult;
import com.zlq.cn.bootstrap.SignApiBootstrap;
import com.zlq.cn.controller.BaseController;
import com.zlq.cn.entity.JuheZw;
import com.zlq.cn.entity.JuheZwContent;
import com.zlq.cn.entity.JuheZwType;
import com.zlq.cn.entity.MaasInvoke;
import com.zlq.cn.service.juhe.JuheZwContentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.zlq.cn.service.juhe.JuheZwService;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 聚合作文 前端控制器
 * </p>
 *
 * @author zhoucl
 * @since 2023-12-13
 */
@Api(tags = "聚合作文")
@RestController
@RequestMapping("/juhe/zw")
public class JuheZwController extends BaseController {

    @Resource
    private JuheZwService juheZwService;

    @Resource
    private JuheZwContentService juheZwContentService;

    @ApiOperation("集合作文列表")
    @PostMapping("/list")
    public SignApiResult<Page<JuheZw>> list(@ApiIgnore @RequestBody JuheZw param) {
        return SignApiResult.resultSuccess(juheZwService.lambdaQuery()
                .like(StringUtils.isNotEmpty(param.getName()), JuheZw::getName, param.getName())
                .eq(Objects.nonNull(param.getGradeId()), JuheZw::getGradeId, param.getGradeId())
                .eq(Objects.nonNull(param.getLevel()), JuheZw::getLevel, param.getLevel())
                .eq(Objects.nonNull(param.getTypeId()), JuheZw::getTypeId, param.getTypeId())
                .eq(Objects.nonNull(param.getWordId()), JuheZw::getWordId, param.getWordId())
                .like(StringUtils.isNotEmpty(param.getWriter()), JuheZw::getWriter, param.getWriter())
                .page(super.<JuheZw>getPage()));
    }

    @ApiOperation("集合作文详情")
    @PostMapping("/content")
    public SignApiResult<JuheZwContent> content(@ApiIgnore @RequestBody JuheZwContent juheZwContent) {
        return SignApiResult.resultSuccess(juheZwContentService.content(juheZwContent));
    }
}

